package com.example.rocketmq;

import lombok.extern.slf4j.Slf4j;
import org.apache.commons.collections.map.HashedMap;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.integration.support.MessageBuilder;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;
import com.example.rocketmq.channel.MyChannel;

import java.util.Map;

@Slf4j
@RestController
@SpringBootApplication
public class RocketmqApplication {

    public static void main(String[] args) {
        SpringApplication.run(RocketmqApplication.class, args);
    }


    @Autowired
    private MyChannel myChannel;

    @GetMapping("/produce")
    public void test(){
        Map<String,String> map = new HashedMap();
        map.put("name","小哈");
        boolean send = myChannel.output().send(MessageBuilder.withPayload(map).build());
        log.info("发送消息:{},结果:{}",map,send);
    }

}
